﻿using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Windows;
using System.Windows.Data;
using System.ComponentModel;
namespace WPFExcelReport
{
    public partial class TSGS01
    {
         
         
        public TSGS01()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VGSDAT();
            DataContext = MV;
            InitializeComponent();
        }

        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            if(dwMain==null)
            { } 
            if (dwMaster != null)
            {
                KEY = "G"+TMV.GSART+TMV.GSVAR ;
                
            }
            else
            {
                KEY = "";
            }
        }
        
        public override void LOADALL()
        {
            dwData = TBMain.NewRow();
            dwData["GSMANDANT"] = app.Mandant;
            dwData["GSART"] = ART;
            SResult = TMV.QGS_1(dwData);
            foreach (DataRow row in SResult.Tables[0].Rows)
            {
                row["KEY"] = Helpers.Helper.GetGB2312Value(row["KEY"].ToString().Trim());
                row["DES"] = Helpers.Helper.GetGB2312Value(row["DES"].ToString().Trim());
            }
            MergeData(SResult, false);
        }

        public override void LOADBYAUF()
        {
            if (ORDERNUM.Length < 23)
                return;

            Locate("KEY", ORDERNUM.Substring(0,24));
        } 

    }
}
